﻿using System;
using fastCSharp;
using fastCSharp.threading;

namespace diantou.examLogServer
{
    /// <summary>
    /// 考试用户信息
    /// </summary>
    internal sealed class examUser : fastCSharp.sql.cache.whole.client.identityMemberCache<examUser>
    {
        /// <summary>
        /// 用户会话标识
        /// </summary>
        private int sessionId;
        /// <summary>
        /// 用户会话标识访问锁
        /// </summary>
        private int sessionIdLock;
        /// <summary>
        /// 检测用户会话标识是否有效
        /// </summary>
        /// <param name="sessionId"></param>
        /// <returns></returns>
        public bool CheckSessionId(int sessionId)
        {
            interlocked.CompareSetYield(ref sessionIdLock);
            if (sessionId >= this.sessionId)
            {
                this.sessionId = sessionId;
                sessionIdLock = 0;
                return true;
            }
            sessionIdLock = 0;
            return false;
        }
        /// <summary>
        /// 考试日志
        /// </summary>
        public list<examLog> Log;
        /// <summary>
        /// 考试日志上一个内容节点
        /// </summary>
        public examUser PreviousLogNode;
        /// <summary>
        /// 考试日志下一个内容节点
        /// </summary>
        public examUser NextLogNode;
        /// <summary>
        /// 编程题考试日志
        /// </summary>
        public examJudgeLog.logs JudgeLog;
        /// <summary>
        /// 编程题考试日志上一个内容节点
        /// </summary>
        public examUser PreviousJudgeLogNode;
        /// <summary>
        /// 编程题考试日志下一个内容节点
        /// </summary>
        public examUser NextJudgeLogNode;
    }
}
